{extend name="public:base"}
{block name="body"}
<body class="pear-container">
    <div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form" action="">
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">用户</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" placeholder="用户手机号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">交易日期</label>
                    <div class="layui-inline" id="login_date">
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" name="start_date" id="start_date"
                                class="layui-input" readonly placeholder="开始日期">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" name="end_date" id="end_date" class="layui-input"
                                readonly placeholder="结束日期">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
			</form>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body">
			<table id="table-list" lay-filter="table-list"></table>
		</div>
	</div>
</body>
{/block}
{block name="custome"}
	<script type="text/html" id="table-toolbar">
	</script>
	<script type="text/html" id="table-bar">
        
	</script>
	{/block}
{block name="script"}
<script type="text/html" id="user-create_time">
        {{layui.util.toDateString(d.create_time, 'yyyy-MM-dd HH:mm')}}
</script>
<script type="text/html" id="trade-type">
    {{# if(d.type == 'recharge'){ }}
        收入
    {{# } }}
    {{# if(d.channel == 'expense'){ }}
        支出
    {{#} }}
</script>
<script type="text/html" id="trade-channel">
    {{# if(d.is_extra == '1'){ }}
        赠送
    {{# } }}
    {{# if(d.is_extra == '0'){ }}
        正常
    {{#} }}
</script>
<script type="text/html" id="user-operator">
    {{# if(d.operator == 'self')  }}
        用户
    {{# } }}
    {{# if(d.operator == 'system')  }}
        系统
    {{# } }}
    {{# if(d.operator == 'admin')  }}
        管理员
    {{# } }}
</script>
<script>
    layui.use(['table', 'form', 'jquery', 'common', 'laydate'], function () {
        let laydate = layui.laydate;
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let cols = [
            [
            {
                title: 'ID',
                field: 'id',
                align: 'center',
            },
            {
                title: '交易手机号',
                field: 'user',               
            },
            {
                title: '账户卡号',
                field: 'card',
                align: 'center',
            },
            {
                title: '交易渠道',
                field: 'type',             
                templet: '#trade-type'
            },
            {
                title: '交易类型',
                field: 'channel',               
                templet: '#trade-channel'
            },
                        
            {
                title: '交易额',
                field: 'amount',

            },
            {
                title: '交易前额度',
                field: 'before_amount',
                
            },
            {
                title: '交易后额度',
                field: 'after_amount',
                
            },
            {
                title: '交易记录',
                field: 'chanage_amount',
                
            },
            {
                title: '备注',
                field: 'remark',
                width:200,
            },
            {
                title: '交易日期',
                field: 'create_time',       
                templet: '#user-create_time'
            },
            {
                title: '操作者',
                field: 'operator',
                templet: '#user-operator'

            },
            ]
        ]

        table.render({
            elem: '#table-list',
            url: '{:url("index")}',
            parseData: function(res){
               $('.layui-table-tool-temp').html(res.msg);
            return {
            "code": res.code, //解析接口状态
            "msg": res.message, //解析提示文本
            "count": res.data.total, //解析数据长度
            "data": res.data.data //解析数据列表
            }},
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#table-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter']
        });
        
    })
</script>
{/block}